package net.asg.games.yokeltowers.view;

import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.MathUtils;
import net.asg.games.yokeltowers.images.ImageProvider;
import net.asg.games.yokeltowers.sounds.SoundManager;

public class YokelGameObjectFactory {

	private ImageProvider imageProvider;
	private SoundManager soundManager;
	public boolean isHitboxActive = false;

	public YokelGameObjectFactory(ImageProvider imageProvider, SoundManager soundManager){
		this.imageProvider = imageProvider;
		this.soundManager = soundManager;
		//System.out.println(soundManager);
	}

	public BlockYokelGameObject getBashBlock() {
		TextureRegion [] textureRegions = new TextureRegion[1];
		textureRegions[0] = imageProvider.getBlockBash();

		return new BlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.BASH_BLOCK);
	}
	public BlockYokelGameObject getEBlock() {
		TextureRegion [] textureRegions = new TextureRegion[1];
		textureRegions[0] = imageProvider.getBlockE();

		return new BlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.E_BLOCK);
	}
	public BlockYokelGameObject getKBlock() {
		TextureRegion [] textureRegions = new TextureRegion[1];
		textureRegions[0] = imageProvider.getBlockK();

		return new BlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.K_BLOCK);
	}
	public BlockYokelGameObject getLBlock() {
		TextureRegion [] textureRegions = new TextureRegion[1];
		textureRegions[0] = imageProvider.getBlockL();

		return new BlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.L_BLOCK);
	}
	public BlockYokelGameObject getOBlock() {
		TextureRegion [] textureRegions = new TextureRegion[1];
		textureRegions[0] = imageProvider.getBlockO();

		return new BlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.O_BLOCK);
	}
	public BlockYokelGameObject getYBlock() {
		TextureRegion [] textureRegions = new TextureRegion[1];
		textureRegions[0] = imageProvider.getBlockY();

		return new BlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.Y_BLOCK);
	}

	public ColumnYokelGameObject getRandomColumn() {
		TextureRegion [] textureRegions = new TextureRegion[1];
		textureRegions[0] = imageProvider.getBlockY();

		return new ColumnYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, getBlock(), getBlock(), getBlock());
	}

	private BlockYokelGameObject getBlock(){
		BlockYokelGameObject yObj = null;

		switch (MathUtils.random(0, 5)){
		case 0:
			yObj = getYBlock();
			break;
		case 1:
			yObj = getOBlock();
			break;
		case 2:        	
			yObj = getKBlock();
			break;
		case 3:        	
			yObj = getEBlock();
			break;
		case 4:        	
			yObj = getLBlock();
			break;
		case 5:        	
			yObj = getBashBlock();
			break;
		}

		return yObj;
	}

}
